package com.xyht.medicine_management_system.modules.visit.controller;


import com.xyht.medicine_management_system.common.commonReturn.ResponseResult;
import com.xyht.medicine_management_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.medicine_management_system.modules.visit.service.MmsMedicineVisitService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 访问表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-12-17
 */
@RestController
@RequestMapping("/visit")
@SecretBody
public class MmsMedicineVisitController {

    @Resource
    private MmsMedicineVisitService medicineVisitService;

    @ApiModelProperty("各药品访问量")
    @GetMapping("/getEachMedicineVisit")
    public ResponseResult getEachMedicineVisit(@RequestParam("classificationId") String classificationId,
                                               @RequestParam("dateType") Integer dateType) {
        return medicineVisitService.getEachMedicineVisit(classificationId, dateType);

    }

    @ApiModelProperty("用户 上个月访问 商品访问量 下单转化率")
    @GetMapping("/getVisitData")
    public ResponseResult getVisitData(){
        return medicineVisitService.getVisitData();

    }

    @ApiModelProperty("药品访问量排名")
    @GetMapping("/getMedicineVisitRanking")
    public ResponseResult getMedicineVisitRanking(){
        return medicineVisitService.getMedicineVisitRanking();

    }

    @ApiModelProperty("总的销售额统计")
    @GetMapping("/getSalesStatistics")
    public ResponseResult getSalesStatistics(@RequestParam(value = "dateType") Integer dateType,
                                             @RequestParam(value = "lastNumber") Integer lastNumber) {
        return medicineVisitService.getSalesStatistics(dateType, lastNumber);

    }

    @ApiOperation("客户购买统计")
    @GetMapping("/getCustomerPurchaseStatistics")
    public ResponseResult getCustomerPurchaseStatistics(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                        @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        return medicineVisitService.getCustomerPurchaseStatistics(pageNum,pageSize);

    }

    @ApiOperation("退货统计")
    @GetMapping("/getReturnStatistics")
    public ResponseResult getReturnStatistics(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                              @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                              @RequestParam(value = "dateType") Integer dateType) {
        return medicineVisitService.getReturnStatistics(pageNum,pageSize,dateType);

    }

    @ApiOperation("商品销售排行")
    @GetMapping("/getMedicineRanking")
    public ResponseResult getMedicineRanking() {
        return medicineVisitService.getMedicineRanking();

    }

    @ApiOperation("药品购买统计")
    @GetMapping("/getMedicineSaleStatistics")
    public ResponseResult getMedicineSaleStatistics() {
        return medicineVisitService.getMedicineSaleStatistics();

    }


}

